import { position2wgs84 } from './utiles'
import polygonmark from "./polygonmark";
class rectanglemark extends polygonmark {

  constructor(options) {
    super(options)
    this._maxPoints = 2
  }

  type = 'rectanglemark'
  name = '矩形'

  /**
   * 设置pos
   * @param {*} pos 
   */
  setPositions(pos) {

    // 生成pos

    if (pos.length == this._maxPoints) {
      let point1 = position2wgs84(pos[0])
      let point2 = position2wgs84(pos[1])
      this._positions = [pos[0], Cesium.Cartesian3.fromDegrees(point2.lng, point1.lat, point1.alt), pos[1], Cesium.Cartesian3.fromDegrees(point1.lng, point2.lat, point1.alt)]
    } else {
      this._positions = pos
    }
  }
}

export default rectanglemark